package com.topnav.mc.admin.entity.enums;

import com.topnav.mc.admin.entity.bean.DeviceAlarmBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 报警类型
 * @Author: kenny
 * @Date: 2023/11/7 15:13
 */
public enum DeviceAlarmCate {
    //1 SOS 报警，2围栏报敬 3 人脸报警， 4 车辆报警

    SOS(1,"SOS"),
    FENCEIN(2,"进围栏"),
    FENCEOUT(3,"出围栏"),
    FACE(4,"人脸识别"),
    VEHICLE(5,"车辆识别"),
    ORTHER(6,"其它");

    private int code;
    private String desc;

    private DeviceAlarmCate(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {return code;}

    public void setCode(int code) {this.code = code;	}

    public String getDesc() {return desc;}

    public void setDesc(String desc) {this.desc = desc;}

    public static List<EnumModal> toList(){
        List<EnumModal> list = new ArrayList<>();
        for (DeviceAlarmCate deviceAlarmCate : DeviceAlarmCate.values()) {
            EnumModal enumModal = new EnumModal();
            enumModal.setIndex(deviceAlarmCate.ordinal());
            enumModal.setCode(deviceAlarmCate.getCode());
            enumModal.setName(deviceAlarmCate.name());
            enumModal.setDesc(deviceAlarmCate.getDesc());
            list.add(enumModal);
        }
        return list;
    }

    public static DeviceAlarmCate getByCode(int code) {
        for (DeviceAlarmCate entity : DeviceAlarmCate.values()) {
            if (entity.getCode() == code) {
                return entity;
            }

        }
        return null;
    }

    public static String getDescByCode(int code) {
        for (DeviceAlarmCate entity : DeviceAlarmCate.values()) {
            if (entity.getCode() == code) {
                return entity.getDesc();
            }

        }
        return null;
    }
}
